#!/bin/sh

if [ -z $1 ];then
   hive_db=default
else
   hive_db=$1
fi

if [ -z $2 ];then
   create_time=`date  "+%Y-%m-%d %H-%M-%S"`
else
   create_time=$2
fi


hiveconfig=$(cat <<"EOF" /home/hdfs/parquet_shell/hive_parquet_scripts/hive.config
EOF
)

sql_suffix=$(cat <<EOF
INSERT INTO TABLE ${hive_db}.navinfo_parquet_0f39 PARTITION (part_time) SELECT tid , gpstime , longitude , latitude , height , direction , speed , alarm , status, faultlist ,${create_time} , originallat, originallng ,mark,  part_time  FROM ${hive_db}.navinfo_stage_0f39 distribute by part_time;
EOF
)

sql="${hiveconfig}${sql_suffix}"
############  execute begin   ###########
hive --hiveconf "tez.queue.name=hive" -S -e "$sql"
#echo $sql
